package com.spring.mvc2.init;

import com.spring.mvc2.config.Appconfig;
import com.spring.mvc2.service.MyInterface;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;

/**
 * @Description TODO
 * @author ll
 */
public class MyWebApplicationInitializer implements WebApplicationInitializer {
	@Override
	public void onStartup(ServletContext servletContext) throws ServletException {
		AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext ();
		context.register(Appconfig.class);

		DispatcherServlet servlet = new DispatcherServlet(context);
		ServletRegistration.Dynamic register = servletContext.addServlet("app", servlet);
		register.setLoadOnStartup(1);
		register.addMapping("/");

	}
}
